package engine.light;

import engine.shader.Shader;

public class SpotLight extends PointLight {
	
	private float[] spotDirection;
	
	private float spotCutoff;
	private float spotExponent;
	
	public SpotLight() {
		super();
		
		spotDirection = new float[4];
	}
	
	public float[] getSpotDirection() {
		return spotDirection;
	}
	
	public void setSpotDirection(float x, float y, float z) {
		spotDirection[0] = x;
		spotDirection[1] = y;
		spotDirection[2] = z;
	}
	
	public void setSpotDirection(float[] spotDirection) {
		setSpotDirection(spotDirection[0], spotDirection[1], spotDirection[2]);
	}

	public float getSpotCutoff() {
		return spotCutoff;
	}

	public void setSpotCutoff(float spotCutoff) {
		this.spotCutoff = spotCutoff;
	}

	public float getSpotExponent() {
		return spotExponent;
	}

	public void setSpotExponent(float spotExponent) {
		this.spotExponent = spotExponent;
	}
	
	@Override
	public void apply(Shader shader, int lightSource) {
		super.apply(shader, lightSource);
		
		shader.sendUniform1f("lights[" + lightSource + "].spotExponent", spotExponent);
		shader.sendUniform1f("lights[" + lightSource + "].spotCutoff", spotCutoff);	
		shader.sendUniform4f("lights[" + lightSource + "].spotDirection", spotDirection);
	}
}
